<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/pagetag.tld" prefix="page" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>用户管理</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css"
          href="<%=request.getContextPath()%>/resources/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css"
          href="<%=request.getContextPath()%>/resources/css/style.css"/>
    <script type="text/javascript"
            src="<%=request.getContextPath()%>/resources/js/jquery.js"></script>
</head>
<body>
<form class="form-inline definewidth m20" action="list.do" method="post">
    passport：
    <input type="text" name="passport" id="passport" class="abc input-default" placeholder=""
           value="${user.passport}">&nbsp;&nbsp;
    <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
    <button type="button" class="btn btn-success" id="add">添加</button>
</form>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <th>用户名</th>
        <th>passport</th>
        <th>mobile</th>
        <th>登录时间</th>
        <th>操作</th>
    </tr>
    </thead>
    <c:forEach items="${page.objList}" var="user">
        <tr id="tr_${user.id}">
            <td>${user.userName}</td>
            <td>${user.passport}</td>
            <td>${user.mobile}</td>
            <td>${user.lastLoginTime}</td>
            <td>
                <a href="redirect.do?type=update&id=${user.id}">编辑</a>
                <a href="javascript:del(${user.id})">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
<page:p url="list.do" condition="" page="${page}"></page:p>
</body>
</html>

<script>
    $(function () {
        $('#add').click(function () {
            window.location.href = "redirect.do?type=save";
        });
    });

    function del(id) {
        if (confirm("确定删除?")) {
            $.post("delete.do?id=" + id, function (data) {
                $('#tr_' + id).remove();
            });
        }
    }
</script>